<% if @purchase_order.errors.any? %>
  <div id="error_explanation">
    <h2><%= pluralize(@purchase_order.errors.count, "error") %> prohibited this purchase_order from being saved:</h2>

    <ul>
    <% @purchase_order.errors.full_messages.each do |msg| %>
      <li><%= msg %></li>
    <% end %>
    </ul>
  </div>
<% end %>

<fieldset>
  <div class="six large-4 columns">
    <label>Supplier</label>
    <%= form.select :supplier_id, @select_suppliers, { include_blank: true }, class: "large-10 " %>

    <label>Invoice Number</label>
    <%= form.text_field :invoice_number %>

    <label>Total Cost</label>
    <%= form.text_field :total_cost %>

    <label>Tracking Number</label>
    <%= form.text_field :tracking_number %>

    <label>Notes</label>
    <%= form.text_field :notes %>

    <label>Ordered At</label>
    <div class='date-select'>
      <%= form.datetime_select :ordered_at %>
    </div>

    <label>Estimated Arrival on</label>
    <div class='date-select'>
      <%= form.date_select :estimated_arrival_on %>
    </div>
  </div>

  <div class=" large-8 columns" style="background-color:#F6F6F6;border: solid 1px #666;">
    <%= form.fields_for :purchase_order_variants, @purchase_order.purchase_order_variants do |po_variant_form| %>
      <%= render partial: 'purchase_order_variant', locals: { po_form: po_variant_form } %>
    <% end %>
    <p><%= link_to "New Variant", '#add_variant', class: 'add_variant tiny button secondary', 'data-association' => "purchase_order_variants" %></p>
    <%= new_child_fields_template form, :purchase_order_variants, form_builder_local: :po_form %>
  </div>
</fieldset>
